COSC 1550 – Introduction to Programming
Test One
Name____________________
Multiple Choice
Circle the letter of the statement that bests answers/completes each question. Each question is worth three points.
1. Even when there is no power to the computer, data can be retained in:
a. Secondary storage
b. The Input Device
c. The Output Device
d. RAM
2. Words that have a special meaning and may only be used for their intended purpose are known as:
a. Operators
b. Programmer Defined Words
c. Key Words
d. Syntax
3. The name for a memory location that may hold data is:
a. Key Word
b. Syntax
c. Operator
d. Variable
4. A _____________ is a complete instruction that causes the computer to perform some action.
a. Line
b. Statement
c. Variable
d. Key Word
5. A variable declaration announces the name of a variable that will be used in a program, as well as:
a. What type of data it will be used to hold
b. The operators that will be used on it
c. The number of times it will be used in the program
d. The area of the code in which it will be used
6. Three primary activities of a program are:
a. Variables, Operators, and Key Words
b. Lines, Statements, and Punctuation
c. Integer, Floating-point and Character
d. Input, Processing, and Output
7. Mistakes that cause a program to produce erroneous results are called:
a. Syntax errors
b. Logic errors
c. Compiler errors
d. Linker errors
8. Computer programs are also known as ___________.
a. hardware
b. firmware
c. software
d. silverware
9. _______ is an example of a volatile type of memory, used for temporary storage.
a. A floppy disk
b. ALU
c. A hard disk
d. RAM
10. _____________ involves rules that must be followed when constructing a program.
a. Syntax
b. Punctuation
c. Portability
d. Operators
11. Which of the following is a preprocessor directive?
a. pay = hours * rate;
b. #include <iostream.h>
c. // This program calculates the user's pay.
d. void main(void)
12. The programmer usually enters source code into a computer using:
a. Pseudocode
b. A text editor
c. A hierarchy chart
d. A compiler
13. In a broad sense, the two primary categories of programming languages are:
a. Mainframe and PC
b. Single-tasking and Multi-tasking
c. Low-level and High-level
d. COBOL and BASIC
14. In the process of translating a source file into an executable file, which of the following is the correct sequence?
a. Source code, preprocessor, modified source code, linker,
object code, compiler, executable code.
b. Preprocessor, source code, compiler, executable code,
linker, modified source code, object code.
c. Source code, compiler, modified source code, preprocessor,
object code, linker, executable code.
d. Source code, preprocessor, modified source code, compiler,
object code, linker, executable code.
15. What is the output of the C++ cout instruction?
cout << 15 / 4 * 4 << endl;
a. 15
b. 12
c. 63
d. 72
16. In programming terms, a group of characters inside a set of double quotation marks is called a:
a. String constant
b. Variable
c. Operation
d. Statement
17. The ________ is used to mark the end of a complete C++ programming statement.
a. Pound Sign
b. Void
c. Data type
d. Semicolon
18. Which character signifies the beginning of an escape sequence?
a. //
b. /
c. \
d. #
19. If you use a C++ Key Word as an identifier, your program will:
a. Execute with unpredictable results
b. Receive a compiler error
c. Refuse to compile
d. Compile, link, but not execute
20. In the C++ instruction, cookies = number % children;
given the following declaration statement:
int number = 38, children = 4, cookies;
what is the value of cookies after the execution of the statement?
a. 2
b. 0
c. 9
d. .5
21. This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires.
a. len
b. bytes
c. sizeof
d. int
22. Character constants in C++ are always enclosed in ______.
a. [brackets]
b. "double
quotation marks"
c. {braces}
d. 'single quotation marks'
23. _______________ are used to declare variables that can hold numbers that contain a decimal point.
a. Integer data types
b. Real data types
c. Floating point data types
d. Long data types
24. The float data type is considered _____ precision, and the double data type is considered _______ precision.
a. single, double
b. float, double
c. integer, double
d. short, long
25. A variable whose value can be either true or false has a data type of:
a. binary
b. float
c. T/F
d. bool
26. How many bytes of memory are needed to store the literal string "This is a test"?
a.. 14
b. 15
c. 16
d. 17
27. A variable's _____ is the part of the program that has access to the variable.
a. data Type
b. value
c. scope
d. reach
28. This control sequence is used to skip over to the next horizontal tab stop.
a. \t
b. \h
c. \n
d. \a
29. Indicate whether the following variable names are valid or invalid. If a variable name is invalid, state the reason why.
a. myName
b. your-Name
c. Bill’sName
d. 3Names
e. return
30. Show the results that will display on the console, when the following code segments are executed. Show a blank line with a series of dots, such as . . . . . . . .
a.
int year = 2004;
cout << "This year is " << year << endl;
cout << "\nNext year is " << year +1 << endl;
cout << "\n\nThe last year is " << "year + 1" << endl;
b.
double length = 10.0;
double width = 2.0;
double area = 0.0;
cout << "The area of a rectangle is " << area << "\n" << endl;
cout << "The area of this rectangle with a length
of "
<< length
<< " and a width of "
<< width
<< " is " << length* width
<< endl;
c.
bool isEmployed = true;
cout << "It is " << isEmployed << " that I have a job" << endl;